#pragma once
#include <Util/BinaryStream.h>
#include <deque>
#include <vector>

#ifdef WIN32
#pragma warning(disable:4200)
#endif

typedef uint16_t MESSAGE_ID;

#pragma pack(1)
struct TcpPacket
{
	const static int32_t MAGIC_NUMBER = 0xDEADBEEF;

	int32_t magicNumber_;
	MESSAGE_ID messageId_;
	int64_t	userid_;
	uint32_t payloadSize_;
	uint8_t payload_[];
};
#pragma pack()

class TcpIncomingPacketProcessor
{
public:
	bool Crop(const char* streamChunk, uint32_t chunkSize, std::deque<TcpPacket*>& packets);
private:
	BinaryStream buffer_;
};

class TcpOutgoinigPacketProcessor
{
public:
	TcpPacket* Pack(MESSAGE_ID id, void* payload, size_t payloadSize, size_t* packetSize);
private:
	std::vector<uint8_t> buffer_;
};